import asyncio
import ygg_aiomysql as aiomysql

async def main():
    # 创建连接池
    pool = await aiomysql.new_pool(
        host='localhost',
        port=3306,
        user='root',
        password='zhangdapeng520',
        db='test'
    )
    
    async with pool.acquire() as conn:
        async with conn.cursor() as cur:
            # 查询所有数据库
            await cur.execute("SHOW DATABASES")
            databases = await cur.fetchall()
            print("所有数据库:")
            for db in databases:
                print(db[0])
    
    # 关闭连接池
    pool.close()
    await pool.wait_closed()

if __name__ == '__main__':
    asyncio.run(main())